#include "stdafx.h"

GUI *gui;
Renderer *renderer;
Pad *pad;

/*
** Render:
** Take a guess what this is used for
*/

void Render()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

	gui->Render();
    pad->Render();

	glEnd();
	glFlush();
}

/*
** Update:
** Called every 100 ms, used for timers and such
*/

void Update(int diff)
{
   	gui->Update();

    Render();

	// Recursive
	glutTimerFunc(1, &Update, 1);   
}

/*
** Called on mouse click event
*/

void MouseClick(int button, int state, int x, int y)
{
    gui->ReceiveClickData(button, state, x, y);
}

/*
** _tmain:
** Main entry point for program
*/

int _tmain(int argc, char** argv)
{
	printf("Launching project...\n");

	/*
	** Initialize glut
	*/

		glutInitWindowSize(640, 360);
		glutInit(&argc, argv);
		glutCreateWindow(PROGRAM_NAME);
		glutTimerFunc(1, &Update, 1);
        glutMouseFunc(&MouseClick);
		glutDisplayFunc(&Render);

	/*
	** Initialize our classes
	*/        
        renderer = new Renderer();
		gui = new GUI();
        pad = new Pad();

	/*
	** Glut begin
	*/
		glutMainLoop();

	return 0;
}